﻿<UserControl x:Class="Berico.SnagL.Infrastructure.Controls.ToolPanel"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    mc:Ignorable="d"
    DataContext="{Binding ToolPanelVM, Source={StaticResource Locator}}"
    d:DesignHeight="300" d:DesignWidth="200"
    Width="Auto" Height="Auto" Visibility="{Binding Visibility}">

    <UserControl.Resources>
        <Style x:Key="CustomAccordionButtonStyle" TargetType="toolkit:AccordionButton">
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Background" Value="White"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Stretch"/>
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
            <Setter Property="IsTabStop" Value="True"/>
            <Setter Property="TabNavigation" Value="Once"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="toolkit:AccordionButton">
                        <Grid Background="Transparent" Margin="{TemplateBinding Padding}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="ExpandDirectionStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="ExpandDown">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="icon">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="icon">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="Width" Storyboard.TargetName="cd0">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Auto"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="Width" Storyboard.TargetName="cd1">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00" To="-90" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="arrow"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="ExpandUp">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="icon">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="icon">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="Width" Storyboard.TargetName="cd0">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="Width" Storyboard.TargetName="cd1">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Auto"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00" To="90" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="arrow"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="ExpandLeft">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="icon">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="icon">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="Height" Storyboard.TargetName="rd0">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Auto"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="Height" Storyboard.TargetName="rd1">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="LayoutTransform" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <TransformGroup>
                                                            <RotateTransform Angle="90"/>
                                                        </TransformGroup>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="arrow"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="ExpandRight">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="icon">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="icon">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Column)" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="(Grid.Row)" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="Height" Storyboard.TargetName="rd0">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="*"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="Height" Storyboard.TargetName="rd1">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Auto"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetProperty="LayoutTransform" Storyboard.TargetName="header">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <TransformGroup>
                                                            <RotateTransform Angle="-90"/>
                                                        </TransformGroup>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00" To="180" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="arrow"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ExpansionStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Collapsed">
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.3" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="icon"/>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Expanded">
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00.3" To="90" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="icon"/>
                                            <!--<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="ExpandedBackground">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFBADDE9"/>
                                            </ColorAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ExpandedBackground">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.5"/>
                                            </DoubleAnimationUsingKeyFrames>-->
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CheckStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="00:00:00"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Checked"/>
                                    <VisualState x:Name="Unchecked"/>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition GeneratedDuration="0"/>
                                        <VisualTransition From="MouseOver" GeneratedDuration="00:00:00.1" To="Normal"/>
                                        <VisualTransition GeneratedDuration="00:00:00.1" To="MouseOver"/>
                                        <VisualTransition GeneratedDuration="00:00:00.1" To="Pressed"/>
                                    </VisualStateGroup.Transitions>
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver">
                                        <Storyboard>
                                            <!--<ColorAnimation BeginTime="0" To="#222" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="arrow"/>-->
                                            <!--<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="MouseOverBackground">
												<SplineColorKeyFrame KeyTime="00:00:00" Value="#FFBADDE9"/>
											</ColorAnimationUsingKeyFrames>-->
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="MouseOverBackground">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.3"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <!--<ColorAnimation BeginTime="0" To="#FF003366" Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" Storyboard.TargetName="arrow"/>
											<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="MouseOverBackground">
												<SplineColorKeyFrame KeyTime="00:00:00" Value="#ff737573"/>
											</ColorAnimationUsingKeyFrames>-->
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation BeginTime="00:00:00" Duration="00:00:00" To=".5" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="DisabledVisualElement" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="FocusStates">
                                    <VisualState x:Name="Focused">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="FocusVisualElement">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="FocusVisualElement">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.385"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unfocused"/>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="background" CornerRadius="1,1,1,1">
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#ff888888"/>
                                        <GradientStop Color="#FF333333" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                                <Grid>
                                    <Border x:Name="ExpandedBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="#FFBADDE9" CornerRadius="1,1,1,1" Height="Auto" Margin="0,0,0,0" Opacity="0" VerticalAlignment="Stretch"/>
                                    <Border x:Name="MouseOverBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="1,1,1,1" Height="Auto" Margin="0,0,0,0" Opacity="0" VerticalAlignment="Stretch">
                                        <Border.Background>
                                            <RadialGradientBrush>
                                                <RadialGradientBrush.RelativeTransform>
                                                    <TransformGroup>
                                                        <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleY="1.965" ScaleX="1.883"/>
                                                        <SkewTransform CenterX="0.5" CenterY="0.5"/>
                                                        <RotateTransform CenterX="0.5" CenterY="0.5" Angle="-44.004"/>
                                                        <TranslateTransform Y="0.33" X="-0.005"/>
                                                    </TransformGroup>
                                                </RadialGradientBrush.RelativeTransform>
                                                <GradientStop Color="#FF4390bb"/>
                                                <GradientStop Color="#00000000" Offset="1"/>
                                            </RadialGradientBrush>
                                        </Border.Background>
                                    </Border>
                                    <Grid Background="Transparent">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition x:Name="cd0" Width="9*"/>
                                            <ColumnDefinition x:Name="cd1" Width="1*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition x:Name="rd0" Height="Auto"/>
                                            <RowDefinition x:Name="rd1" Height="Auto"/>
                                        </Grid.RowDefinitions>
                                        <Grid x:Name="icon" Grid.Column="1" HorizontalAlignment="Right" Height="19" Grid.Row="0" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Center" Width="19">
                                            <Grid.RenderTransform>
                                                <TransformGroup>
                                                    <ScaleTransform/>
                                                    <SkewTransform/>
                                                    <RotateTransform Angle="-90"/>
                                                    <TranslateTransform/>
                                                </TransformGroup>
                                            </Grid.RenderTransform>
                                            <Path x:Name="arrow" Data="M1.5,1.904605 L22.173403,21.865133 M42.500004,1.5 L22.539474,22.173403 M1.5,31.904606 L22.173403,51.865131 M42.500004,31.5 L22.539474,52.173401" HorizontalAlignment="Stretch" Height="Auto" Margin="3" RenderTransformOrigin="0.5,0.5" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeEndLineCap="Square" Stroke="#FFFBFAFA" Stretch="Fill" StrokeThickness="3" VerticalAlignment="Stretch" Width="Auto">
                                                <Path.RenderTransform>
                                                    <TransformGroup>
                                                        <ScaleTransform/>
                                                        <SkewTransform/>
                                                        <RotateTransform/>
                                                        <TranslateTransform/>
                                                    </TransformGroup>
                                                </Path.RenderTransform>
                                            </Path>
                                        </Grid>
                                        <toolkit:LayoutTransformer x:Name="header" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Foreground="White" FontWeight="Bold" FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="Center" Margin="6,5,0,5" Grid.Row="0" Grid.RowSpan="1"/>
                                    </Grid>
                                </Grid>
                            </Border>
                            <Rectangle x:Name="FocusVisualElement" IsHitTestVisible="False" RadiusY="1" RadiusX="1" Stroke="#FF4390bb" StrokeThickness="2" Visibility="Collapsed"/>
                            <Rectangle x:Name="DisabledVisualElement" IsHitTestVisible="False" Opacity="0" Fill="White" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot" Background="SlateGray">
        <toolkit:Accordion ExpandDirection="Down" SelectionMode="ZeroOrMore" HorizontalContentAlignment="Stretch"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Items}" AccordionButtonStyle="{StaticResource CustomAccordionButtonStyle}" >
            <toolkit:Accordion.ItemContainerStyle>
                <Style TargetType="toolkit:AccordionItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="VerticalContentAlignment" Value="Stretch" />
                    <Setter Property="Background" Value="LightGray" />
                </Style>
            </toolkit:Accordion.ItemContainerStyle>

            <!-- The buttons below are just for designing purposes-->
            <toolkit:AccordionItem Header="Test 1" IsEnabled="True" IsSelected="True" />
            <toolkit:AccordionItem Header="Test 2" IsEnabled="True" IsSelected="True" />
        </toolkit:Accordion>
    </Grid>
    
</UserControl>
